<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>物业管理系统</title>
    <base href="<%=basePath%>"> 
 		<link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/vivo.css">
    <link rel="stylesheet" href="css/cmxform.css">
    <meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>

	
	
	<script src="js/jquery-1.11.1.js"></script>
	<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
    <script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script> 
    <script type="text/javascript" src="js/sharefunction.js"></script>
    <script language="javascript" type="text/javascript"
			src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
			
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>	
		<style type="text/css">
			.primary-vdd {
			color: #fff;
			background-color: #5a98de;
			border-color: #5a98de
			}

			.primary-vdd:hover
				{
				color: #fff;
				background-color: #0a6999;
				border-color: #0a6999
			}
		</style>
	<script type="text/javascript">
		
		$.validator.setDefaults({
		    submitHandler: function() {
		      	saveDocument();
		    }
		});
		
		$(document).ready(function() {
			$("#watchType").select2({minimumResultsForSearch:-1});
		    $("#commentForm").validate({
		    	errorPlacement: function(error, element) {
					// Append error within linked label
					$( element ).next().append( error );
				},
				errorElement: "span",
				rules: {
					reading:{
					maxlength: 9,
					max:999999,
					min:0
					}
				},
				messages: {
					typeName: {
						required: " 必需字段!",
						minlength: " (不能少于 3 个字母)"
					},
				unitNumber:{
					required:" 必须字段！ "
				},
				watchNo:{
					number:"请输入合法编号！ "
				},
				reading:{
					maxlength:"输入的数字超范围",
					max:"输入的数字超范围",
					min:"输入的数字超范围",
					number:"请输入合法数字! ",
					required:"请输入最新读数！ "
				},
				watchName:{
					required:"请输入表具名称！"
				},
			
				readTime:{
					required:"请输入读数日期！ "
				}
			}
				
		    });
		    
		
		    
		});
		
		function saveDocument(){
			var roomInfo=$("#roomInfo").val();
			var watchType=$("#watchType").val();
			var watchName=$("#watchName").val();
			var watchNo=$("#watchNo").val();
			var reading=$("#reading").val();
			var readTime=$("#readTime").val();
			//layer.confirm("确定保存吗？",{icon:3},function(i){
				var url="room/roomWatch/add1";
				jQuery.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{watchType:watchType,
			        		watchName:watchName,
			        		watchNo:watchNo,
			        		reading:reading,
			        		readTime:readTime,
			        		roomInfoId:roomInfo},
				    success:function(data){
							            if(data.success){					            			
			        		 						window.parent.layer.msg('保存成功！');
			        		 						var recordId="aa1123";
			        		 						var indext="1";
							   						var params="&recordId="+recordId+"&indext="+indext;
													window.parent.gridObj4.options.otherParames=params;
													window.parent.gridObj4.refreshPage();
			        		 						window.parent.gridObj.refreshPage();
							           				window.parent.document.getElementById("xinzengbianjidushu").style.display='none';
			        		 						closeLayer(); 
							            		
							   	        }else{
							            	layer.alert(data.msg,{icon:7});
							            }
							        }
		   		});
			//});
		}
	</script>
	
	</head>
	<body>
	<form class="cmxform" id="commentForm" method="get" action="">
		<div style="padding:20px">
			<div class="panel panel-default">
				<div class="panel-heading">
      				<h5 class="panel-title">基本信息</h5>
   			  	</div>
	   			<div class="panel-body">
				<table cellpadding="10" cellspacing="5" class="mytable">
					<tr>
					<td width="90">类别</td>
					<td width="250px">
						<select   id="watchType" style="width:90px;">
							<option value="0">冷水表</option>
							<option value="1">热水表</option>
							<option value="2">电表</option>
						</select>
					</td>		
				</tr>		
				<tr>
					<td width="90">表具名称</td>
					<td><input type="text" name="watchName" id="watchName" required/><font color="red"> *</font><span style="color:red"></span> </td>
					
					<td width="90">表具编号</td>
					<td>
						<input type="text" name="watchNo" id="watchNo" class="number"><span style="color:red"></span>
						<input type="hidden" name="roomInfo" id="roomInfo" value="${roomInfoId}">
					</td>
				</tr>
				<tr>
					<td width="90">最新读数</td>
					<td><input type="text" name="reading" id="reading" class="number" required/><font color="red"> *</font><span style="color:red"></span> </td>
					<td width="90">读数日期</td>
					<td>
						<input type="text" name="readTime" id="readTime" class="Wdate"
												onClick="WdatePicker()" required /><font color="red"> *</font>
										</td>
					
				</tr>
				
			</table>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius primary-vdd" type="submit" > 保 存</button> 
				 <a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
	    	 </div>
		
		
		<input id="typeChoice" name="typeChoice" type="hidden" value="${typeChoice}"/>
		</form>
  	</body>
  	
   </html>
  	
